//
//  TalkVoiceTableViewCell.m
//  模拟-百思不得姐
//
//  Created by 程春玉 on 16/8/18.
//  Copyright © 2016年 colin. All rights reserved.
//

#import "TalkVoiceTableViewCell.h"
#import <AVFoundation/AVFoundation.h>

@interface TalkVoiceTableViewCell()

@property (nonatomic, strong) AVAudioPlayer *play;

@end
@implementation TalkVoiceTableViewCell

- (void)getVoiceWithVoicePath:(NSString *)voicePath
{
    NSData *data = [NSData dataWithContentsOfURL:[NSURL URLWithString:voicePath]];
    NSError *error = nil;
    self.play = [[AVAudioPlayer alloc] initWithData:data error:&error];
    if (!error) {
        _play.volume = 1.0f;
        self.timeLabel.text = [NSString stringWithFormat:@"%.2f秒", _play.duration];
    } else {
        NSLog(@"%@", error);
    }
}


- (void)awakeFromNib {
    [super awakeFromNib];
    self.selectionStyle = UITableViewCellSelectionStyleNone;
    self.backgroundColor = [UIColor clearColor];
    // Initialization code
}

- (IBAction)voiceBtn:(id)sender {
    [self.play play];
}


- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
